<?php
 include_once('connection/connection.php');
	$data=$_GET['data'];
    $val=$_GET['val'];
	$val2=$_GET['val2'];
	
	$deg=$_GET['deg'];
	$mi=$_GET['mi'];
	$se=$_GET['se'];
	
	$Edeg=$_GET['Edeg'];
	$Emi=$_GET['Emi'];
	$Ese=$_GET['Ese'];
	
function getName($colName,$id)
{
	$sqlgetName="select distinct ".$colName."_name from tbl_lookup_location where ".$colName."_id=".$id;
	$querygetName=mysql_query($sqlgetName);
	$rowgetName=mysql_fetch_row($querygetName);
	return $rowgetName[0];
}


	
	 if($data=='form_id')
	 {	
          echo "<select name='block' id='block' class='txt'>\n";
          echo "<option value='0'>==== Block ====</option>\n";
		    $val2=$val;
         	$val = substr($val,0,10);
		   $query="select DISTINCT block_id from tbl_lookup_location where district_id='$val'";
		   $result=mysql_query($query);
       
		     while(list($id)=mysql_fetch_array($result))
		        {
                  $block_name[$id]=getName('block',$id);
                }
		          asort($block_name);
         
		          foreach($block_name as $key=>$val)
		        	{
			           echo "<option value=\"$key\">".$val."</option> \n" ;
			        }
         
		  echo "</select>";  	
		}
	
	 if($data=='rain')
	 {	
      $numrows=$val-$val2;
	  ?>
	  <input type="hidden" name="numfield" id="numfield" value="<?php echo $numrows;?>" />
	   <table width="744" border="0">
  <tr>
    <td width="144" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Year</font></td>
    <td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Annual Rainfall (mm)</font></td>
    <td width="146" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Annual Rainydays (nos)</font></td>
    <td width="152" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Highest Rainfall (mm)</font></td>
    <td colspan="2" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;On Date</font></td>
  </tr>
  <?php
	  for($i=0;$i<=$numrows;$i++)
	  {
	 
	  ?>
	 
  <tr bgcolor="#F7F7F7">
    <td><input type="text" value="<?php echo $val2;?>" name="period<?php echo $i;?>" readonly="readonly" style="background-color:#E6E6E6" /></td>
    <td><input type="text" name="rainfall<?php echo $i;?>" id="rainfall<?php echo $i;?>"></td>
    <td><input type="text" name="raindays<?php echo $i;?>" id="raindays<?php echo $i;?>"></td>
    <td><input type="text" name="Hrain<?php echo $i;?>" id="Hrain<?php echo $i;?>"></td>
    <td width="64">
	<select name="Day<?php echo $i;?>" id="Day<?php echo $i;?>" style="font-size:10px;">
				<option value="0">Day</option>
				<?php
					
				for($Day=1;$Day<=31;$Day++)
				{
				?>
				<option value="<?php echo $Day;?>"><?php echo $Day;?></option>
				<?php
				}
				?>
	  </select>
	</td>
    <td width="60" align="left">
	<select name="Month<?php echo $i;?>" id="Month<?php echo $i;?>" style="font-size:10px;">
				<option value="0">Month</option>
				<option value="Jan">Jan</option>
				<option value="Feb">Feb</option>
				<option value="March">March</option>
				<option value="April">April</option>
				<option value="May">May</option>
				<option value="June">June</option>
				<option value="July">July</option>
				<option value="Aug">Aug</option>
				<option value="Sep">Sep</option>
				<option value="Oct">Oct</option>
				<option value="Nov">Nov</option>
				<option value="Dec">Dec</option>
				</select>
	</td>
  </tr>


	  <?php
	   $val2=$val2+1;
	  }
	  ?>
	  <input type="hidden" name="num_row" id="num_row" value="<?php echo $numrows;?>" />
</table>
	  <?php
	 }	
	 
	 if($data=='con')
	 {
	 
	 $convertedValue=$deg+($mi/60)+($se/3600);
	 $EconvertedValue=$Edeg+($Emi/60)+($Ese/3600);
	 ?>
	              <table width="194" border="1">
                  <tr>
                    <td width="144" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Degree decimal</font> </td>
                    <td width="34" align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Zone</font></td>
                  </tr>
                  <tr>
                    <td>
					<input type="text" name="lat" id="lat" value="<?php echo $convertedValue;?>" readonly="readonly"></td>
                    <td align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;N</font></td>
                  </tr>
                  <tr>
                    <td><input type="text" name="long" id="long" value="<?php echo $EconvertedValue;?>" readonly="readonly"></td>
                    <td align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;E</font></td>
                  </tr>
                </table>
	 
	 <?php
	 } 
		
?>
